//
//  LoginViewController.m
//  mendianjieke
//
//  Created by 响当当 on 8/1/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "LoginViewController.h"
#import "GetMeeageView.h"
#import "LoginView.h"

@interface LoginViewController ()
@property (nonatomic, strong)GetMeeageView *messageView;
@property (nonatomic, strong)LoginView *loginView;
@end

@implementation LoginViewController

- (LoginView *)loginView
{
    if (!_loginView)
    {
        _loginView = [[LoginView alloc]initWithFrame:CGRectMake(0,NAVIBAR_HEIGHT,SCREEN_WIDTH,SCREEN_HEIGHT - NAVIBAR_HEIGHT)];
        WeakSelf(self)
        _loginView.changeViewBlock = ^(NSString *phoneNum) {
            [weakSelf changeView:phoneNum];
        };
    }
    return _loginView;
}

- (GetMeeageView *)messageView
{
    if (!_messageView)
    {
        _messageView = [[GetMeeageView alloc]initWithFrame:CGRectMake(SCREEN_WIDTH,NAVIBAR_HEIGHT,SCREEN_WIDTH,SCREEN_HEIGHT - NAVIBAR_HEIGHT)];
    }
    return _messageView;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    [self setTitle:@"导购专家"];
    
    [self.view addSubview:self.loginView];
    
}

- (void)backAction
{
    [UIView animateWithDuration:0.2 animations:^{
        [self.messageView cancelTime];
        [self.loginView setX:0];
        [self.messageView setX:SCREEN_WIDTH];
    } completion:^(BOOL finished) {
        if (self.messageView)
        {
            [self.messageView removeFromSuperview];
        }
//        [self cancelBackBtn];
    }];
}

#pragma mark - method
- (void)changeView:(NSString *)phoneNum
{
    [self.view addSubview:self.messageView];

    [UIView animateWithDuration:0.2 animations:^{
        [self.loginView setX:-SCREEN_WIDTH];
        [self.messageView setX:0];
    } completion:^(BOOL finished) {
        [self setDefaultNav];
        [self.messageView getPhoneNum:phoneNum];
        [self.messageView sentPhoneCodeTimeMethod];
    }];
}
@end
